<?php
declare (strict_types = 1);

namespace app\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\facade\Cache;
use think\facade\Db;

class test extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('test')
            ->setDescription('the test command');
    }

    protected function execute(Input $input, Output $output)
    {
        /*$id = 1;
        $goodsInfo = Db::name('goods')->where(["id"=>$id])->find();
        Cache::set('good_info_'.$id,$goodsInfo);
        $goodsInfos = Cache::get('good_info_'.$id);
        var_dump($goodsInfos);*/

        $redis = new \Redis();
        $redis->connect('127.0.0.1',6379);
        $redis->auth('123456');

       /* $countNum = $redis->lpop('list_key_goods');//减少库存
        var_dump($countNum);die;*/
        $data = [
            'id' =>2,
            'count' =>1,
            'title' =>'油泼面',
            'amount' =>'10.00',
        ];
        for ($i=1;$i<=100;$i++){
            $data = [
                'id' =>$i,
                'count' =>1,
                'title' =>'油泼面_'.$i,
                'amount' =>'10.00',
            ];
            $redis->lPush('list_key_goods',json_encode($data));
        }

        // 指令输出
        $output->writeln('test');
    }
}
